// pages/game/game.js
import regeneratorRuntime from '../../plugins/regenerator-runtime.js'
import { Request_API_CN, Request_API_COM } from '../../utils/index.js'//封装请求
const app = getApp();
import { prefix, surface } from '../../api/config.js';
Page({
  data: {
    url:'',
    orderId: ''
  },
  onLoad: function (options) {
    let orderId = options.orderId;
    this.data.orderId = options.orderId;
    if(options.game == 'demo') {
      this.setData({
        url: 'https://www.yyjpai.cn/lipstick/demo/index.html'
      })
      wx.setNavigationBarTitle({
        title: '体验',
      })
    } else {
      this.setData({
        url: 'https://www.yyjpai.cn/lipstick/formal/mobile/play.html?game_id=formal&user_id=' + app.globalData.openid + '&game_pay=6&product_id=' + orderId + '&randomNum=3233&forecast_result=1111'
      })
      wx.setNavigationBarTitle({
        title: '闯三关，赢口红',
      })
    }
  },
  gameResult: function (e) {
    let data = JSON.parse(e.detail.data[0]);
    Request_API_CN(prefix+'/endGame', 'POST', { lrid: this.data.orderId, result: data.results});
  }
})